define(['app'], function(app) {
	'use strict';

	// 实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_list(result){
			if(false){
				result = '{"success":true,"msg":"","result":{"advertis":[{"id":"001","video_name":"扳手介绍","video_image":"","video_url":"","company_profile":"博世企业","apply_time":"2017/01/01 09:00:00","view_count":1},{"id":"002","video_name":"工具介绍","video_image":"","video_url":"","company_profile":"博世企业","apply_time":"2017/01/01 09:00:00","view_count":10}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		
		// 返回信息
		return {
			get_list : function(type,key, nPage, order, callback, calldone) {
				Http.post({
					method : 'info.starenterprise.search',
					key:key,
					nPage:nPage,
					pagelimit:10,
					order:order,
					type:type
				},function(result){
					if(callback)
						callback(get_data_list(result).result);
				},function(e){

				},function(){
					if(calldone)
						calldone();
				});
			}

		};
	}

	factory.$inject = [ 'Http' ];
	return app.registerService("Star", factory);
});